//C13:ep13_3_1.c: read data from a file ,output to console.
#include <stdio.h>
#include <stdlib.h>
#define SIZE 4

struct studetn_st
{
    char name[15];
    int num;
    int age;
    char addr[20];
}stud[SIZE];

int main(void)
{
    int i;
    FILE *fp;

    fp = fopen("stu_list.txt", "r");

    if(fp == NULL)
    {
        fprintf(stderr, "cannot open readfile!");
    }

    for(i = 0; i < SIZE; i++)
    {
        fread(&stud[i], sizeof(struct studetn_st),1,fp);
        printf("%-10s %4d %4d %-15s\n", stud[i].name, stud[i].num,
                stud[i].age, stud[i].addr);
    }
    fclose(fp);
    exit(0);
}

